package gui.customizer.panes.netfilter;

import java.awt.event.ActionListener;
import java.io.IOException;
import java.util.List;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JPanel;

import net.SSHConnection;
import net.SSHConnectionProxy;

import core.models.NatRule;

public abstract class NatConfigurable extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 9012617397029261655L;
	protected JButton btnAdd;
	public abstract void setRule(NatRule rule);
	public abstract NatRule getRule();
	public abstract void resetFields();
	
	public void addListenerToAddButton(ActionListener l) {
		btnAdd.addActionListener(l);
	}
	
	protected DefaultComboBoxModel getAvailableInterfaces() throws IOException {
		if (!SSHConnectionProxy.isConnected())
			return null;
		SSHConnection conn = new SSHConnectionProxy();
		List<String> interfaces = conn.getInterfacesNames();
		DefaultComboBoxModel model = new DefaultComboBoxModel();
		model.addElement("-none-");
		for (String iface : interfaces) {
			model.addElement(iface);
		}
		return model;
	}
}
